package com.abel.bigwater.data.jnrq

import org.joda.time.Period
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component

@Component
object JnrqSettings {

    /**上传周期
     * ssH miH hhH ddH
     */
    @Value("\${upload.period.jnrq}")
    val uploadPeriodStr: String? = null

    val uploadPeriod: Period
        get() = if (uploadPeriodStr.isNullOrEmpty()) Period(6, 0, 0, 0)
        else Period.parse(uploadPeriodStr!!)

    /**
     * 抄表周期
     */
    @Value("\${read.period.jnrq}")
    val readPeriodStr: String? = null

    val readPeriod: Period
        get() = if (readPeriodStr.isNullOrEmpty()) Period(0, 10, 0, 0)
        else Period.parse(readPeriodStr)

    /**
     * 上传时刻
     */
    @Value("\${upload.clock.jnrq}")
    val uploadClockStr: String? = null

    val uploadClock: Period
        get() = if (uploadClockStr.isNullOrEmpty()) Period(0, 18, 0, 0)
        else Period.parse(uploadClockStr)

    /**
     * 抄表时刻
     */
    @Value("\${read.clock.jnrq}")
    val readClockStr: String? = null

    val readClock: Period
        get() = if (readClockStr.isNullOrEmpty()) Period(0, 0, 28, 0)
        else Period.parse(readClockStr)
}